//
//  Event.m
//  XPhoto
//
//  Created by baboy on 2019/8/7.
//  Copyright © 2019 baboy. All rights reserved.
//

#import "Event.h"
#import <BKKit/BKApi.h>
#import "HttpResponse.h"

@implementation Event

+ (id)searchWithArgs:(EventSearchArgs *)args
            callback:(void(^)(id task, id events, NSError *error))callback{
    
    id task = [BKApi request:API_EVENT_SEARCH
                parameters:args
                  callback:^(id  _Nonnull task, id  _Nullable json, NSError * _Nullable error) {
                      HttpResponse *response = [HttpResponse responseWithDictionary:json dataItemClass:[Event class]];
                      if (!error && ![response isSuccess]) {
                          error = [NSError errorWithDomain:HttpRequestDomain code:response.status userInfo:@{NSLocalizedDescriptionKey:response.msg}];
                      }
                      if (callback) {
                          callback(task, response.data,error);
                      }
                  }];
    return task;
}
@end

@implementation EventSearchArgs

@end
